package models

import (
	"gorm.io/gorm"
	"time"
)

type Resume struct {
	gorm.Model
	ID              uint             `json:"id"`
	Title           string           `json:"title"`
	CreatedAt       string           `json:"created_at"`
	UpdatedAt       string           `json:"updated_at"`
	Avatar          string           `json:"avatar"`
	Name            string           `json:"name"`
	Email           string           `json:"email"`
	Wechat          string           `json:"wechat"`
	Phone           string           `json:"phone"`
	Website         string           `json:"website"`
	Github          string           `json:"github"`
	CSDN            string           `json:"csdn"`
	Description     string           `json:"description"`
	Media           []Media          `json:"medias" gorm:"foreignKey:ResumeID;references:ID"`
	TechStacks      []TechStack      `json:"tech_stacks" gorm:"many2many:resume_tech_stacks;"`
	Educations      []Education      `json:"educations" gorm:"foreignKey:ResumeID;references:ID"`
	WorkExperiences []WorkExperience `json:"work_experiences" gorm:"foreignKey:ResumeID;references:ID"`
	Projects        []Project        `json:"projects" gorm:"foreignKey:ResumeID;references:ID"`
}

type TechStack struct {
	gorm.Model
	ID    uint   `json:"id"`
	Style string `json:"style"`
	Name  string `json:"name"`
}

type ResumeTechStack struct {
	gorm.Model
	ID                uint
	ResumeID          uint `json:"resume_id"`
	TechStackID       uint `json:"tech_stack_id"`
	Familiarity       int  `json:"familiarity"`
	YearsOfExperience int  `json:"years_of_experience"`
}

type Media struct {
	gorm.Model
	ID       uint   `json:"id"`
	Type     int    `json:"type"`
	ResumeID uint   `json:"resume_id"`
	Name     string `json:"name"`
	Logo     string `json:"logo"`
	QRCode   string `json:"qr_code"`
}

type Education struct {
	gorm.Model
	ID        uint      `json:"id"`
	ResumeID  uint      `json:"resume_id"`
	Major     string    `json:"major"`
	Level     int       `json:"level"`
	SchoolID  uint      `json:"school_id"`
	StartTime time.Time `json:"start_time"`
	EndTime   time.Time `json:"end_time"`
	School    School    `json:"school" gorm:"foreignKey:ResumeID;references:ID"`
}

type Project struct {
	gorm.Model
	ID          uint             `json:"id"`
	ResumeID    uint             `json:"resume_id"`
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Gallery     []ProjectGallery `json:"gallery" gorm:"foreignKey:ProjectID;references:ID"`
	TechStacks  []TechStack      `json:"tech_stacks" gorm:"many2many:project_tech_stacks;"`
}

type ProjectTechStack struct {
	gorm.Model
	ID          uint   `json:"id"`
	ProjectID   uint   `json:"project_id"`
	TechStackID string `json:"tech_stack_id"`
}

type ProjectGallery struct {
	gorm.Model
	ID        uint   `json:"id"`
	ProjectID uint   `json:"project_id"`
	ImageURL  string `json:"image_url"`
}

type WorkExperience struct {
	gorm.Model
	ID          uint      `json:"id"`
	ResumeID    uint      `json:"resume_id"`
	CompanyName string    `json:"company_name"`
	CompanyLogo string    `json:"company_logo"`
	JobTitle    string    `json:"job_title"`
	StartTime   time.Time `json:"start_time"`
	EndTime     time.Time `json:"end_time"`
}

type School struct {
	gorm.Model
	ID    uint   `json:"id"`
	Name  string `json:"name"`
	Logo  string `json:"logo"`
	Is985 *bool  `json:"is985"`
	Is211 *bool  `json:"is211"`
}
